<template>
  <div class="banner">
    <el-carousel height="400px">
      <el-carousel-item v-for="item in banner_list">
        <router-link :to="item.link_url">
          <img :src="item.image" alt=""> <!--图片需要从后端返回-->
        </router-link>

      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
export default {
  name: "Banner",
  data() {
    return {
      banner_list: []
    }
  },

  created() {
    // vue对象创建时触发方法
    this.$axios.get(this.$settings.base_url + '/home/banner/').then(response=>{
      this.banner_list = response.data.result
    }).catch(error=> {
      console.log(error)
    })
  }


}
</script>

<style scoped>
.el-carousel__item {
  height: 400px;
  min-width: 1200px;
}
.el-carousel__item img {
  height: 400px;
  margin-left: calc(50% - 1920px / 2);
}
</style>